package com.acwing.partition21;

import java.io.*;

/**
 * @author `RKC`
 * @date 2022/3/11 10:55
 */
public class AC2068整数拼接_哈希表 {

    private static final int N = 100010;
    private static int[] a = new int[N];
    private static int[][] s = new int[11][N];
    private static int n, k;

    private static final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    private static final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        String[] ss = reader.readLine().split(" ");
        n = Integer.parseInt(ss[0]);
        k = Integer.parseInt(ss[1]);
        ss = reader.readLine().split(" ");
        for (int i = 0; i < n; i++) a[i] = Integer.parseInt(ss[i]);
        //a * len % k = -b % k，其中len为b的长度
        //预处理
        for (int i = 0; i < n; i++) {
            int t = a[i] % k;
            for (int j = 0; j < 11; j++) {
                s[j][t]++;
                t = t * 10 % k;
            }
        }
        long ans = 0;
        for (int i = 0; i < n; i++) {
            int len = getLen(a[i]), t = a[i] % k;
            ans += s[len][(k - t) % k];
            //去重
            int r = t;
            //等价于求a[i]乘以10^len的余数，同上面的预处理求法一样
            while (len-- > 0) r = r * 10 % k;
            if (r == (k - t) % k) ans--;
        }
        writer.write(ans + "\n");
        writer.flush();
    }

    private static int getLen(int num) {
        int res = 0;
        while (num != 0) {
            res++;
            num /= 10;
        }
        return res;
    }
}
